package com.erli.exchange.common.context;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

/**
 * 
 * @Package com.erli.exchange.common.context   
 * @ClassName:  ApiRequestContext   
 * @Description:TODO
 * @Author: LeeHo
 * @Date:   2019年3月16日 下午10:28:25   
 *
 */
@Getter
@Setter
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class ApiRequestContext {

	@SuppressWarnings("rawtypes")
	private static ThreadLocal threadLocal = new ThreadLocal() {
		@Override
		protected ApiRequestContext initialValue() {
			return null;
		}
	};
	
	//请求URI
	private String requestUri;
	
	//客户端IP
	private String clientIp;
	
	//登陆Token
	private String loginToken;
	
	//用户ID
	private Integer userId;
	
    public static ApiRequestContext getThreadLocal() {
        return (ApiRequestContext) threadLocal.get();
    }

    @SuppressWarnings("unchecked")
	public static void setThreadLocal(ApiRequestContext context) {
        threadLocal.set(context);
    }

    public static void removeThreadLocal() {
        threadLocal.remove();
    }
	

}
